//
//  AboutViewController.m
//  JiuLe
//
//  Created by 黄鑫 on 16/9/1.
//  Copyright © 2016年 Fine. All rights reserved.
//

#import "AboutViewController.h"
#import "Common.h"
#import "OpinionViewController.h"
#import "ProtocolViewController.h"

@interface AboutViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *iamgeNew;
@property (weak, nonatomic) IBOutlet UILabel *labServer;

@end

@implementation AboutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"关于久乐";
    [self showNavgationWithLeftItemWithTitle:@"我的"];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
     _iamgeNew.hidden = YES;
     NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
     CFShow((__bridge CFTypeRef)(infoDic));
     NSString *currentVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];
     _labServer.text = [@"久乐健康" stringByAppendingString:currentVersion];
     [Common checkVersionUpdate:^(BOOL isSuccess, BOOL isUpdate, BOOL isNewfeatures, NSDictionary *updateInfo) {
         if (isSuccess && isUpdate) {
             _labServer.text = [@"最新版本" stringByAppendingString:[updateInfo objectForKey:@"version"]];
             _iamgeNew.hidden = NO;
         } else {
             _iamgeNew.hidden = YES;
         }
     }];
}


#pragma mark - UITableview Datasource
//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//    UILabel *lab = [cell viewWithTag:1];
//    NSLog(@"%@",lab.text);
//    if ([lab.text isEqualToString:@"发现新版本"]) {
//        [[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://itunes.apple.com/us/app/ebus/id%@?mt=8&uo=4",kAPPID]]];
//    }else if ([lab.text isEqualToString:@"用户协议"]){
//        ProtocolViewController *protocol = [[UIStoryboard storyboardWithName:@"PersonalViewController" bundle:nil] instantiateViewControllerWithIdentifier:@"ProtocolViewController"];
//        [self.navigationController pushViewController:protocol animated:YES];
//    }else if ([lab.text isEqualToString:@"意见反馈"]){
//        OpinionViewController *versionVC = [[UIStoryboard storyboardWithName:@"PersonalViewController" bundle:nil] instantiateViewControllerWithIdentifier:@"OpinionViewController"];
//        [self.navigationController pushViewController:versionVC animated:YES];
//    }else if ([lab.text isEqualToString:@"给我评分"]){
//        [[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=%@&pageNumber=0&sortOrdering=2&type=Purple+Software&mt=8",kAPPID]]];
//    }
//    [tableView deselectRowAtIndexPath:indexPath animated:YES];
//}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
//    if (SCREEN_HEIGHT == 480) {
//        if (indexPath.row == 0) {
//            return 139;
//        }else if(indexPath.row == 5){
//            return 111;
//        }else{
//            return 50;
//        }
//    }else{
//        if (indexPath.row == 0) {
//            return 139;
//        }else if(indexPath.row == 5){
//            NSLog(@"%f",SCREEN_HEIGHT - 64 - 139 - (4*50));
//            return SCREEN_HEIGHT - 64 - 139 - (4*50)-44;
//        }else{
//            return 50;
//        }
//    }
    if (indexPath.row ==0) {
        return 140;
    }else
    {
        return 100;
    }
    

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
